﻿using System;
using System.Web;
using Test.DAL;
using Test.IDAL;

namespace Test
{
    /// <summary>
    /// DelClass 的摘要说明
    /// </summary>
    public class DelClass : IHttpHandler
    {
        IClassInfoDAL bll = new ClassInfoDAL();
        public void ProcessRequest(HttpContext context)
        {
            var id = context.Request.Form["cid"];
            if (string.IsNullOrWhiteSpace(id))
            {
                context.Response.Write("参数丢失");
            }
            else {
                var cid = Convert.ToInt32(id);
                var result = bll.Delete(new Model.ClassInfo() { Id = cid });
                if (result.States &&result.Data > 0)
                {
                    context.Response.Write(1);
                }
                else {
                    context.Response.Write(result.message);
                }
            }


            context.Response.ContentType = "text/plain";
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}